#ifndef WG_RESOURCE_MODEL_HEADER
#define WG_RESOURCE_MODEL_HEADER

#include "cJSON.h"
#include "random.h"

typedef struct resource_model resource_model;
typedef struct mode mode;
typedef struct mode_definition_list mode_definition_list;

/**
 * The struct passed to the resource thread that starts the workload
 */
struct resource_model {
  void (*birth)(void *);
  void *state;
  mode **modes;
  int cnt_modes;
};

struct mode {
  void *(*function)(void *);
  char *key;
  double probability;
};

struct mode_definition_list{
  mode_definition_list *next;
  char *key;
  mode *(*build_mode)(cJSON *);
};

mode * select_mode(resource_model *);
void install_mode(mode_definition_list *[HASHSIZE], char *, mode *(*)(cJSON *));
mode **initialize_modes(mode_definition_list *[HASHSIZE], cJSON *);
int count_modes(cJSON *);

#endif
